#!/bin/bash
dir="$(pwd)/pushgateway_data"
mkdir -p "$dir"

min=5.0
max=100.0
rand_num=$(awk -v min=1.5 -v max=98.0 'BEGIN{srand(); printf("%.3f\n", min+rand()*(max-min))}')
rand_num2=$(awk -v min=1.5 -v max=78.0 'BEGIN{srand(); printf("%.3f\n", min+rand()*(max-min))}')

cat > "$dir/metrics.txt" <<EOF
# TYPE C1 counter
ceshi1{status="200"} ${RANDOM}
ceshi2{status="500"} ${RANDOM}
# TYPE C2 gauge
ceshiA{sensor="A"} ${rand_num}
ceshiB{sensor="B"} ${rand_num2}
EOF

curl -X POST --data-binary @"$dir/metrics.txt" \
  http://192.168.84.202:9091/metrics/job/ceshi_metrics/instance/192.168.84.202